package Java实验.实验七;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketTest_s {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(9999);

        //监听客户端连接
        Socket s = ss.accept();

        InputStream is = s.getInputStream();
        byte[] bys = new byte[1024];
        int len = is.read(bys);
        System.out.println("客户端发来消息：" + new String(bys, 0, len));

        OutputStream os = s.getOutputStream();
        os.write("你好客户端1号".getBytes());

        ss.close();
    }
}
